﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OutStock.aspx.cs" Inherits="Services_OutStock" %>
<html>
<head>
<title>批发开票</title>
<link href="../css/adminCss.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/rl.js"></script>
<script type="text/javascript" src="../js/submit.js"></script>
<script type="text/javascript">
//-------------通过型号编号获取产品信息-----------------------------------------------------------
var xmlHttp1; 
var ajaxresponsevalue1;
function createXMLHttpRequest1() { 
    if (window.ActiveXObject) { 
        xmlHttp1 = new ActiveXObject("Microsoft.XMLHTTP"); 
    } 
    else if (window.XMLHttpRequest) { 
        xmlHttp1 = new XMLHttpRequest(); 
    } 
} 

function startRequest(type) {  
    if(document.getElementById('ComodBarcode').value!=''||document.getElementById('Spec').value!=''){
        document.getElementById('Msg').innerHTML = "正在获取商品信息...";
        document.getElementById("Msg").style.visibility="visible";
        createXMLHttpRequest1(); 
        xmlHttp1.onreadystatechange = handleStateChange; 
        xmlHttp1.open("POST",'DataCode.aspx?type='+escape(type)+'&id='+escape(document.getElementById('ComodBarcode').value)+"&ModelId="+escape(document.getElementById('Spec').value), true); 
        xmlHttp1.send(null); 
    }
} 

function handleStateChange() { 
    if(xmlHttp1.readyState == 4) { 
        if(xmlHttp1.status == 200) { 
        //alert(xmlHttp1.responseText);
        getDownListData(xmlHttp1.responseText);		    
        }
         
    } 
} 

function getDownListData(paramValue)
{
    if(paramValue!="")//返回值
    {
       document.getElementById("HidTypeId").value=paramValue.split('||')[0];
       document.getElementById("TypeName").value=paramValue.split('||')[1];
       document.getElementById("catalogueName").value=paramValue.split('||')[2];
       document.getElementById("ComodBarcode").value=paramValue.split('||')[3]; 
       document.getElementById("Units").value=paramValue.split('||')[4];
       document.getElementById("Spec").value=paramValue.split('||')[5];// 
       document.getElementById("ProcMoney").value=paramValue.split('||')[6];//成本价
       document.getElementById("Retail").innerText=paramValue.split('||')[7];//价格
       document.getElementById("Prices").value=paramValue.split('||')[7];//应收单价
       document.getElementById("TotalMoney").value=paramValue.split('||')[7];//应收单价
       document.getElementById("SelNum").innerText=paramValue.split('||')[8];//库存
       document.getElementById("btnAd").disabled="";
       document.getElementById("btnAd").focus();
       //生成库存数量下拉表
         
    }else{
       document.getElementById("TypeName").value="";
       document.getElementById("catalogueName").value="";
       //document.getElementById("ComodBarcode").value=""; 
       document.getElementById("Units").value="";
       //document.getElementById("Spec").value="";// 
       document.getElementById("ProcMoney").value="";//成本价
       document.getElementById("Retail").innerText="";//价格
       document.getElementById("Prices").value="";//应收单价
       document.getElementById("TotalMoney").value="";//应收单价
       document.getElementById("OutNum").value="";//数量
       document.getElementById("SelNum").innerText="0";//删除全部
       document.getElementById("btnAd").disabled=true;
    }
    document.getElementById("Msg").style.visibility="hidden";
}
//-------------END 通过型号编号获取产品信息-----------------------------------------------------------

function end()//获取客户信息资料是否完整
{

    if(document.getElementById("HidCountNum").value!="0" && document.getElementById("maintmen").value!="" && document.getElementById("EditDate").value!="")
    {
        document.getElementById("btnAdd").disabled="";
    }
    else
    {
        document.getElementById("btnAdd").disabled=true;       
    }
}

function account()
{
    var sl=document.getElementById("OutNum").value;//数量
    var dj=document.getElementById("Prices").value;//应收单价
    var sumPrice=0;//合计

    if(sl!=""&&dj!=""&&!isNaN(sl)&&!isNaN(dj))
    {
        sumPrice=parseFloat(sl)*parseFloat(dj);
        document.getElementById("TotalMoney").value=sumPrice.toFixed(2);
    }
}
     
function check(id)
{
    if(parseFloat(document.getElementById("OutNum").value) <= 0)
    {
        alert('数量不能小于0！')
        return false;
    }
 }
</script>
<link href="../js/loading.css" rel="stylesheet" type="text/css" />
</head>
<script type="text/javascript" src="../js/loading.js" charset="gb2312"></script>
<body>
    <form id="form1" runat="server" onSubmit="return checknull(this)">
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td align="center" width="31" height="22"><img src="../images/module.gif" width="20" height="22"></td>
                <td width="50%"><asp:Label ID="Path" runat="server"></asp:Label></td>
                <td width="990" align="right"><a href="javascript:location.href=document.referrer;" ><img src="../images/history.gif" border="0" /></a></td>
            </tr>
      </table>
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td bgcolor="#3CB6E5" height="5px"></td>
            </tr>
        </table>
        <table border="0" width="100%" cellpadding="1" cellspacing="1" class="tabGg">
            <tr>
                <td colspan="6" bgcolor="#FFFFFF" height="27">
					<div class="left">单号：<asp:Label ID="Dh" runat="server"></asp:Label>
                    <div id="Msg" style="position: absolute; width: 120px; height: 20px; z-index: 1;border: 1px solid #ff0000; background-color: #FEEED3; layer-background-color: #FEEED3;filter: alpha(opacity=50); visibility: hidden;"></div></div>
				</td>
            </tr>
            <tr>
                <th width="15%" height="27"  class="r_bg nobr">
                    编号条码：</th>
                <td   class="right_bg">
                    <input name="ComodBarcode" type="text" style="width: 100px" id="ComodBarcode"   onKeyUp="startRequest(1)" onChange="startRequest(1)" class="input1" runat="server" /></td>
                <th width="15%"  class="r_bg nobr">备件规格：</th>
                <td   class="right_bg" ><input name="Spec" type="text" style="width: 100px" id="Spec" onKeyUp="startRequest(2)"  onchange="startRequest(2)"  class="input1" runat="server" /></td>
                <th width="15%"  class="r_bg">单位：</th>
                <td height="27"  class="right_bg" ><input name="Units" type="text" style="width: 50px;" class="input1" id="Units"  runat="server" /></td>
            </tr>
            <tr>
                <th height="28"  class="r_bg" > 商品大类：</th>
                <td  class="right_bg"><INPUT style="WIDTH: 100px" id="TypeName" class="input1" name="TypeName" runat="server" /></td>
                <th  class="r_bg  nobr">
                    配件名称：</th>
                <td  class="right_bg" ><INPUT style="WIDTH: 100px" id="catalogueName" class="input1" name="catalogueName" runat="server" /></td>
                <th  class="r_bg nobr">
                    成交单价：</th>
                <td height="28"  class="right_bg">
                    <input name="txtCmoney" type="text" style="width: 50px;" value="0" class="input1" id="Prices"   onfocus="if(this.value==0)this.value=''" onBlur="if(this.value=='')this.value=0"    onkeyup="value=value.replace(/[^\d]/g,'');account()"  runat="server" />元 </td>
            </tr>
            <tr>
                <th height="28"  class="r_bg">单价：</th>
                <td  class="right_bg"><asp:Label ID="Retail" runat="server"></asp:Label></td>
               <th  class="r_bg">数 &nbsp; 量：</th>
                <td  class="right_bg" ><input name="text" type="text" class="input1"  id="OutNum" style="width: 50px"  value="0" runat="server"  onkeyup="account()"  />
                    库存：<asp:Label ID="SelNum" runat="server" CssClass="F_red"></asp:Label></td>
                <th  class="r_bg">成交合计：</th>
                <td height="28"  class="right_bg"><input name="TotalMoney" type="text" style="width: 50px;" class="input1" id="TotalMoney"  runat="server"   readonly="readOnly"/>元</td>
            </tr>
      </table>
                    <asp:GridView ID="gvData" runat="server" Width="100%" CssClass="gridview" AutoGenerateColumns="False">
                        <PagerSettings Visible="False" />
                        <Columns>
                            <asp:BoundField HeaderText="配件大类" DataField="LS_band">
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:BoundField HeaderText="配件名称" DataField="LS_name">
                                <ItemStyle HorizontalAlign="Center" />                            
                            </asp:BoundField>
                            <asp:BoundField HeaderText="条码" DataField="LS_BarCode">
                                <ItemStyle HorizontalAlign="Center" /> 
                            </asp:BoundField>
                            <asp:BoundField HeaderText="数量" DataField="LS_num">
                                <ItemStyle HorizontalAlign="Center" /> 
                             </asp:BoundField>
                            <asp:TemplateField HeaderText="单价">
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("LS_practical","{0:f2}") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="金额">
                                <ItemTemplate>
                                    <asp:Label ID="Label0" runat="server" Text='<%# Bind("LS_TotalPractical","{0:f2}") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:BoundField HeaderText="单位" DataField="LS_unit">
                                <ItemStyle HorizontalAlign="Center" />                            </asp:BoundField>
                            <asp:TemplateField HeaderText="删除">
                                <ItemTemplate>
                                    <asp:LinkButton ID="linkDel" CommandArgument='<%#Eval("id") %>' runat="server" ForeColor="Red"
                                        OnClick="linkDel_Click">删除</asp:LinkButton>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                    <table width="100%" border="1">
                        <tr>
                            <td style="width: 407px">                            </td>
                            <td style="width: 98px">                            </td>
                            <td>                            </td>
                        </tr>
                        <tr>
                            <td style="45%" align="center">本单合计</td>
                            <td style="width: 98px"><asp:Label ID="Xnum" runat="server" ForeColor="Red" Text="0"></asp:Label></td>
                            <td><asp:Label ID="Xmoney" runat="server" ForeColor="Red" Text="0"></asp:Label></td>
                        </tr>
                    </table>
                    <div class="center margin_bottom2 margin_top2"><asp:Button ID="btnAd" CssClass="submit" runat="server" Text="添加商品" OnClientClick="return check(this.form)"    OnClick="btnAd_Click" Enabled="False" /></div>
			
        <table border="0" width="100%" cellpadding="1" cellspacing="1" class="tabGg">
            <tr>
                <td width="15%"  class="r_bg nobr" >领货人：</td>
                <td width="35%" class="right_bg"><asp:DropDownList ID="maintmen" runat="server" onchange="end()">
                  <asp:ListItem Value="">选择人员</asp:ListItem>
                </asp:DropDownList></td>
              <td width="15%"  class="r_bg">备注说明：</td>
               <td width="35%" class="right_bg"><asp:TextBox ID="Remark" runat="server" CssClass="input1" ></asp:TextBox></td>
            </tr>
            <tr>
                <td  class="r_bg" >操作员：</td>
                <td  class="right_bg"><asp:Label ID="Name" runat="server"></asp:Label></td>
                <td  class="r_bg nobr">出货日期：</td>
                <td  class="right_bg"><asp:TextBox ID="EditDate" runat="server" CssClass="input1" Width="80px"  onclick="SelectDate(this.name)"  ></asp:TextBox></td>
            </tr>
            <tr>
                <td  class="r_bg"> <asp:HiddenField ID="HidCountNum" runat="server" /></td>
                <td colspan="3"  class="right_bg"><asp:Button ID="btnAdd" CssClass="submit" runat="server" Text="确认出货"   OnClick="btnAdd_Click" Enabled="False" />
                    &nbsp; &nbsp;
                    <asp:CheckBox ID="isprint"  runat="server" Checked="True" Text="是否打印" /></td>
            </tr>
        </table>
        <asp:HiddenField ID="ProcMoney" runat="server" />
        <asp:HiddenField ID="Hidid" runat="server" />
        <asp:HiddenField ID="Hidsj2" runat="server" />
        <asp:HiddenField ID="hidsj" runat="server" />
        <asp:HiddenField ID="Hidware" runat="server" />
        <asp:HiddenField ID="HidTypeId" runat="server" />
        <asp:HiddenField ID="hidModuid" runat="server" />
    </form>
</body>
</html>

